﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Proggy.Web.Cms.PropertyTypes;
using Proggy.Web.Cms.Core.Models;
using Proggy.Web.Cms.Core.Configuration.ConfigObjects;
using Proggy.Web.Cms.Core.Configuration;
using Newtonsoft.Json;

namespace Proggy.Web.Cms.Core.PropertyTypes
{
    /// <summary>
    /// Proggy editor property type - drag and drop content
    /// </summary>
    [PropertyType("Drag and drop content", "~/Areas/ProggyCore/Views/EditorPartials/DragAndDropEditor.cshtml", RequiredConfigObjectType=typeof(DragAndDropConfigObject))]
    public class DragAndDrop : ConfigurablePropertyTypeBase, IValidatablePropertyType, IAutoRenderPropertyType
    {
        /// <summary>
        /// The items added to the page
        /// </summary>
        public AddedDragAndDropItem[] AddedDragAndDropItems { get; set; }

        /// <summary>
        /// Validate
        /// </summary>
        /// <param name="vContext"></param>
        /// <param name="attr"></param>
        /// <returns></returns>
        public Tuple<bool, string> GetIsValid(System.ComponentModel.DataAnnotations.ValidationContext vContext, ContentModel.ContentModelPropertyTypeAttribute attr)
        {
            //
            return new Tuple<bool, string>(true, "");
        }

        public object GetAutoRenderModel()
        {
            return this.AddedDragAndDropItems;
        }

        [JsonIgnore]
        public string FullPathToAutoRenderPartial
        {
            get { return "~/Areas/ProggyCore/Views/AutoRenderPartials/_DragAndDrop.cshtml"; }
        }
    }
}
